﻿using Comm100.Framework.Domain.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Bot.Domain.Entities;
using Bot.Domain.Interfaces;
using Bot.Domain.Bo;
using Castle.Windsor;
using Bot.Domain.Specifications;

namespace Bot.Domain.Categories.Service
{
    public class SmartTriggerActionSelectedDepartmentDomainService : ISmartTriggerActionSelectedDepartmentDomainService
    {
        private IWindsorContainer _container;
        private readonly IRepository<Guid, SmartTriggerActionSelectedDepartment> _repository;

        public SmartTriggerActionSelectedDepartmentDomainService(IRepository<Guid, SmartTriggerActionSelectedDepartment> repository, IWindsorContainer container)
        {
            this._repository = repository;
            this._container = container;
        }

        public SmartTriggerActionSelectedDepartment Create(SmartTriggerActionSelectedDepartment category)
        {
            return _repository.Create(category);
        }

        public SmartTriggerActionSelectedDepartment Get(Guid id)
        {
            return _repository.Get(id);
        }

        public SmartTriggerActionSelectedDepartment Update(SmartTriggerActionSelectedDepartmentUpdateBo bo)
        {
            SmartTriggerActionSelectedDepartment smartTriggerActionSelectedDepartment = _repository.Get(bo.Id);
            smartTriggerActionSelectedDepartment.Id = bo.Id;
            smartTriggerActionSelectedDepartment.SmartTriggerActionId = bo.SmartTriggerActionId;
            smartTriggerActionSelectedDepartment.DepartmentId = bo.DepartmentId;
            
            _repository.Update(smartTriggerActionSelectedDepartment);

            return smartTriggerActionSelectedDepartment;

        }

        public IEnumerable<SmartTriggerActionSelectedDepartment> List()
        {
            return _repository.ListAll();
        }
        public IEnumerable<SmartTriggerActionSelectedDepartment> GetByActionId(Guid actionId)
        {
            return _repository.List(new SmartTriggerActionSelectedDepartmentFilterSpecification(actionId));
        }
        public void Delete(Guid id)
        {
            SmartTriggerActionSelectedDepartment smartTriggerActionSelectedDepartment = _repository.Get(id);

            _repository.Delete(smartTriggerActionSelectedDepartment);

        }
    }
}
